package com.hk.rabbitmq.two;

import com.hk.rabbitmq.utils.RabbitMqUtils;
import com.rabbitmq.client.CancelCallback;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;
import com.rabbitmq.client.Delivery;

/**
 * @author: dpb
 * @date: 2022/3/10
 * 工作线程
 */
public class Work01 {
    private final static String QUEUE_NAME = "hello";

    public static void main(String[] args) throws Exception {

        Channel channel = RabbitMqUtils.getChannel();

        DeliverCallback deliverCallback = (consumerTag, message) -> {
            String msg = new String(message.getBody());
            System.out.println("接收到的消息：" + msg);
        };
        CancelCallback cancelCallback = (String consumerTag) -> {
            System.out.println("消费被中断了！！！");
        };

        System.out.println("消费者启动等待消费消息。。。。。。。。");
        /**
         * 1、
         * 2、
         * 3、
         * 4、
         *
         */
        channel.basicConsume(QUEUE_NAME, true, deliverCallback, cancelCallback);
    }
}
